package com.ustudy.entity.cms;

import java.util.Collections;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.ustudy.core.dao.support.entity.StringIdEntity;

import com.ustudy.entity.commons.PagesTemplate;

/**
 * 前台页面菜单
 * @author Hector
 *
 */
@SuppressWarnings("serial")
@Entity(name="PageMenus")
@Table(name="CMS_PAGE_MENUS")
public class PageMenus extends StringIdEntity {
	
	private String name;
	
	@ManyToOne(cascade={CascadeType.REFRESH},fetch=FetchType.LAZY)
	@JoinColumn(name="PARENT_ID")
	private PageMenus parent;
	
	@ManyToOne(cascade={CascadeType.REFRESH},fetch=FetchType.LAZY)
	@JoinColumn(name="TPL_ID")
	private PagesTemplate pagesTemplate;
	
	@OneToMany(cascade={CascadeType.ALL},fetch=FetchType.LAZY,mappedBy="parent")
	private List<PageMenus> children=Collections.emptyList();
	
	@Column
	@Lob
	@Basic(fetch=FetchType.LAZY)
	private String body;
	
	private PageMenuType pageMenuType=PageMenuType.SYS;
	
	private Long sortInfo=System.currentTimeMillis();
	
	public static enum PageMenuType{
		SYS("系统内置"),CMS("CMS"),EC("电子商务"),LMSG("留言"),FORUM("论坛"),LINK("外链");
		private final String label;
		private PageMenuType(String label){
			this.label=label;
		}
		public String getLabel() {
			return label;
		}
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public PageMenus getParent() {
		return parent;
	}

	public void setParent(PageMenus parent) {
		this.parent = parent;
	}

	public List<PageMenus> getChildren() {
		return children;
	}

	public void setChildren(List<PageMenus> children) {
		this.children = children;
	}

	public String getBody() {
		return body;
	}

	public void setBody(String body) {
		this.body = body;
	}

	public PageMenuType getPageMenuType() {
		return pageMenuType;
	}

	public void setPageMenuType(PageMenuType pageMenuType) {
		this.pageMenuType = pageMenuType;
	}

	public Long getSortInfo() {
		return sortInfo;
	}

	public void setSortInfo(Long sortInfo) {
		this.sortInfo = sortInfo;
	}

	public PagesTemplate getPagesTemplate() {
		return pagesTemplate;
	}

	public void setPagesTemplate(PagesTemplate pagesTemplate) {
		this.pagesTemplate = pagesTemplate;
	}
}
